package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
*
*
*/
public class Test2 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method[] methods = cls.getMethods();
        for(Method m : methods) {
            if (m.getParameterCount() == 0 && m.getModifiers() == Modifier.PUBLIC) {
                System.out.println("调用" + m.getName() + "()");
                m.invoke(obj);
            }
        }
    }
}
